package kr.hkit.powerjava.chapter10;

//import javax.swing.JOptionPane;

public class ArrayTest1 {

	public static void main(String[] args) {
		final int STUDENT = 5;

		int[] arrScores = new int[STUDENT];
//		System.out.println(arrScores.length);

		for (int i = 0; i < arrScores.length; i++) {
			/*
			//다른 입력 방식(스캐너 대신)
			arrScores[i] = Integer.parseInt(
					JOptionPane.showInputDialog("점수를 입력하시오")
					);// return 타입이 string이라서 래퍼클래스로 parseInt함
			*/
			arrScores[i] = i+1;
		}
		
		prnArray(arrScores);
		arrSum(arrScores);
		
		int[] arr = {1,2,3,4,5,6,7,8,9};
		System.out.println(arr.length);
		
		for(int i: arr){//확장된 for only 출력용도
			System.out.printf("%3d",i);
		}
	}

	private static void arrSum(int[] arrScores) {
		int sum = 0;
		for(int i=0; i<arrScores.length; i++){
			sum+=arrScores[i];
		}
		System.out.println("배열 arrScores의 요소들의 합은 "+sum+"이다.");
	}

	private static void prnArray(int[] arrScores) {
		for(int i=0; i<arrScores.length; i++){
			System.out.print(arrScores[i] + "\t");
		}
		
	}
}
